<?php 
include_once('connection/connection.php');
//session_start();
//ob_start();
include('header.php');
include('config.php');
include('menu.php');
//$loginid=$_SESSION['loginid'];
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="css/style_question.css" type="text/css" rel="stylesheet" />
<title>Create User</title>
</head>
<body>
<div align="right">
<?php

$dir_id= "";
$doc = date("d-m-Y");





if($_REQUEST['usertype'] == 1)  $dir_id = 0;
else if($_REQUEST['usertype'] == 2) $dir_id = $_REQUEST['zone'];
else if($_REQUEST['usertype'] == 3) $dir_id = $_REQUEST['circle'];
else if($_REQUEST['usertype'] == 4) $dir_id = $_REQUEST['division'];
else if($_REQUEST['usertype'] == 5) $dir_id = $_REQUEST['sub_division'];


$query1=mysql_query("SELECT user_id FROM tbl_lookup_user WHERE login_id='$_REQUEST[login_id]' ");

if(mysql_num_rows($query1) == 0 )
{


	if(mysql_query("INSERT INTO tbl_lookup_user VALUES('','$_REQUEST[name]','$_REQUEST[login_id]','$_REQUEST[password]','$_REQUEST[emailid]','$_REQUEST[designation]','$_REQUEST[usertype]','$dir_id','$doc','1')"))
	{
		echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have Created User Successfully . Now you can go on <a href="home.php">home</a> page or <a href="create_user.php">Create</a> User again. An email has been sent to user\'s email address, before login, he should follow the email to confirm his email address.</span>';
									$to = trim($_REQUEST['emailid']);
									$subject = 'Confirmation mail';
									$body = "Hello " . ucwords($_REQUEST['name']) . ", \n\n Welcome!! to Benchmarking of Rural Drinking Water Supply Schemes in Rajasthan. \n\n Your Login Id :- " . $_REQUEST['login_id']  . " \n\nPassword :- " . $_REQUEST['password'] . " \n\n Now you are " . $type[$_REQUEST['usertype']] . " type of user. To activate your account, please click on this link:\n\n";
									$body .= 'http://www.ramkydelhi.com/phed';
									$body = wordwrap($body,70);
									$header = "MIME-Version: 1.0\r\n"; 
									$header .="From:Ramky {admin@ramky.com}\r\n"; 
									mail($to,$subject,$body,$header);
									//mail($to,$subject,$body);
				
	}
	else 
	{
		//echo "Some problem inserting record";
		echo'<h3>Sorry, some error occured, please try again after sometime.<h3>';
	}

}
else
{
	echo'<span class="successmssg"><b>Sorry!!</b><br/>Loginid or Email-id Already Exist.Please Create user with anothe name<a href="create_user.php">Create User</a>.</span>';

}

?>
</div>
</body>
</html>